var logic_urls = {
	login:'/home/login/login',
	index:'/home/apps/index',
	houseList:'/home/apps/houseList',
	truckByCode:'/home/apps/truckByCode',
    codeNumber:'/home/apps/codeNumber',
    checkBillCode:'/home/apps/checkBillCode',
    saveBill:'/home/apps/saveBill',
    saveTruckEmpty:'/home/apps/saveTruckEmpty',
    getWeighList:'/home/apps/getWeighList',
    editBill:'/home/apps/editBill',
    delBill:'/home/apps/delBill',
    getUnableBills:'/home/apps/getUnableBills',
    getCountWeigh:'/home/apps/getCountWeigh',
    getAllUserList:'/home/apps/getAllUserList',
    exitProgram:'/home/apps/exitProgram',
    getNormalReport:'/home/apps/getNormalReport',
    resetPassword:'/home/apps/resetPassword',
    setPassword:'/home/apps/setPassword',
    saveUsers:'/home/apps/addUsers',
    deleteUsers:'/home/apps/deleteUsers',
    setUserPower:'/home/apps/setUserPower',
    truckAdd:'/home/apps/truckAdd',
    truckSave:'/home/apps/truckSave',
    truckDel:'/home/apps/truckDel',
    exportNormalReport:'/home/index/exportNormalReport',
    customerSave:'/home/apps/customerSave',
    customerDel:'/home/apps/customerDel',
    goodsSave:'/home/apps/goodsSave',
    goodsDel:'/home/apps/goodsDel',
    excavatorSave:'/home/apps/excavatorSave',
    excavatorDel:'/home/apps/excavatorDel',
    houseSave:'/home/apps/houseSave',
    houseDel:'/home/apps/houseDel',
    trucktypeSave:'/home/apps/trucktypeSave',
    trucktypeDel:'/home/apps/trucktypeDel',
    configSave:'/home/apps/configSave',
    configDel:'/home/apps/configDel',
    positionSave:'/home/apps/positionSave',
    positionDel:'/home/apps/positionDel',
    routeSave:'/home/apps/routeSave',
    routeDel:'/home/apps/routeDel',
    serialnumberSave:'/home/apps/serialnumberSave',
    printCountAdd:'/home/apps/printCountAdd',
    changeBillDate:'/home/apps/changeBillDate',
    getWillChangeBillList:'/home/apps/getWillChangeBillList',
    changeBillLocked:'/home/apps/changeBillLocked',
    getBase:"/admin/apps/getBase",
    adminLogin:"/admin/login/login",
    adminDel:"/admin/apps/adminDel",
};

function QueryString(key){
    var a = window.location.search.substr(1).split('&')
    if (a == "") return "";
    var b = {};
    for (var i = 0; i < a.length; ++i)
    {
        var p=a[i].split('=');
        if (p.length != 2) continue;
        b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
    }
    if(b[key])
        return b[key];
    else
        return "";
};

var logic_house = {
	cookie_name:'logic_house',
	houseId:'',
	houseName:'',
	read:function(){
		var this_read = $.cookie(this.cookie_name);
		console.log($.cookie(this.cookie_name));
		if(this_read){
			this_read = JSON.parse(this_read);
			for(var k in this_read){
				this[k] = this_read[k];
			}
		}
	},
	save:function(){
		var out = {};
        for(var k in this)
            if(!jQuery.isFunction(this[k]))
                out[k] = this[k];
        var save_string = JSON.stringify(out);

        $.cookie(this.cookie_name,save_string,{expires:30});
        console.log($.cookie('logic_house'));
	},
	onSignin:function(dt){
        for(var k in dt){
            this[k] = dt[k];
        }
        this.save();
    },
};
var logic_user = {
	cookie_name:"lgoic_user",
	userName:'',
	is_sign_in:false,
	read:function(){
        var cookie_data = $.cookie(this.cookie_name);
        if(cookie_data){
            cookie_data = JSON.parse(cookie_data);
            //if(cookie_data.mobile)
                for(var k in cookie_data)
                    this[k] = cookie_data[k];
        }
    },
    save:function(){
        var out = {};
        for(var k in this)
            if(!jQuery.isFunction(this[k]))
                out[k] = this[k];
        var save_string = JSON.stringify(out);

        $.cookie(this.cookie_name,save_string);
        console.log($.cookie(this.cookie_name));
    },
    onSignin:function(dt){
        for(var k in dt){
            this[k] = dt[k];
        }
        this.save();
    },
	signout:function(signout_ok,signout_error){
		this["is_signin"] = false;
		this.save();
   },
}
Date.prototype.format = function(fmt) { 
     var o = { 
        "M+" : this.getMonth()+1,                 //月份 
        "d+" : this.getDate(),                    //日 
        "h+" : this.getHours(),                   //小时 
        "m+" : this.getMinutes(),                 //分 
        "s+" : this.getSeconds(),                 //秒 
        "q+" : Math.floor((this.getMonth()+3)/3), //季度 
        "S"  : this.getMilliseconds()             //毫秒 
    }; 
    if(/(y+)/.test(fmt)) {
            fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length)); 
    }
     for(var k in o) {
        if(new RegExp("("+ k +")").test(fmt)){
             fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
         }
     }
    return fmt; 
}